<?php

namespace app\admin\controller;
use app\common\controller\Adminbase;
use think\Controller;
use think\Db;
use think\Request;
use think\Session;
/**
 * 招财树 控制器
 */
//class Money extends AdminBase {
  class Money extends controller {
	 /**
     * 招财树
     * @return
     */
     public function Money(){

    	return $this->fetch();
    }
     /**
     * 招财树
     * @return
     */
     public function Statistics(){

    	return $this->fetch();
    }
     /**
     * 招财树
     * @return
     */
     public function Statistics_1(){

    	return $this->fetch();
    }
     /**
     * 提现配置
     * @return
     */
     public function withdrawal(){
            $big = input("param.big")*100;
            $little = input("param.little")*100;
            Db::name("withdrawal")
                ->delete(true);
            $data = [
                'big'=>$big,
                'little'=>$little,
            ];
            $result= Db::name('withdrawal')
                    ->insert($data);
         if($result){
             return json(['code' => 1, 'url' => '', 'msg' => '提现配置成功']);
         }else{
             return json(['code' => 0, 'url' => '', 'msg' => '提现配置失败']);
         }
    }
     /**
     * 提现配置（查询）
     * @return
     */
     public function withdrawal_quey(){
     	$result = Db::name('withdrawal')->find();

     	return json($result);
    }
    /**
     * 提现记录（查询）
     * @return
     */
    public function withdrawal_record(){
        $where = [];
        $player_id = input("param.player_id");
        $nickname = input("param.nickname");
        $time = input("param.time");
        if($player_id != 0){
            $where['player_id'] = $player_id;
        }
        if($nickname !=""){
            $where['nickname'] = $nickname;
        }
        if($time !="" ){
            $start_time = substr($time,0,10)." "."00:00:00";
            $end_time = substr($time,13)." "."23:59:59";
            $where['cash_time'] =array(array('Egt',$start_time),array('Elt',$end_time), 'and');
        }
        $result = Db::name('player_cash')
               ->where($where)
               ->order('cash_time desc')
                ->select();
        foreach ($result as $k=>$v){
            $result[$k]['fee'] = $v['cash']/100;
        	$result[$k]['nickname'] = base64_decode($v['nickname']);
        
        }

        return json($result);
    }
}